package com.itheima.demo02;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

/**
 * @author Zhang_Han
 * @version 10.0
 * @date 2020/7/20 10:51
 */
@SuppressWarnings("all")
public class Demo_Test {
    public static void main(String[] args) throws Exception {

        //获取字节码对象 ;
        Class clazz = Class.forName("com.itheima.demo02.UseTest");

        Constructor constructor = clazz.getConstructor();

        UseTest test = (UseTest) constructor.newInstance();
        //获取里面的所有方法;
        Method[] methods = clazz.getDeclaredMethods();

        //遍历数组 拿出每一个方法进行判断;

        for (Method method : methods) {

            //进行判断 ;
            if (method.isAnnotationPresent(Test.class)) {
                method.invoke(test);
            }

        }
    }
}
